import http from "@/utils/http";
import type {
  WorkbenchCount,
  WorkbenchMsgListParams,
  MsgPageListData,
  MsgConfirmParams,
  MsgPageListParams,
  msgPageListCountData
} from "@/apis";
import type { AuditListParams, AuditModelListParams, auditCheckModelType } from "@/apis/audit/types";

/**
 * 获取所有分组流程表单数据
 */
export const modelGroupList = (params: AuditModelListParams) => {
  return http.get("/process/model/listAll", params);
};
/**
 * 查询我有权处理的表单
 */
export const myHandelmodelList = (type: auditCheckModelType) => {
  return http.get(`/process/task/taskModelList/${type}`);
};

/**
 * 待我处理
 */
export const pendingAuditList = (data: AuditListParams) => {
  return http.get("/process/task/todoList", data);
};

/**
 * 我已处理
 */
export const alreadyAuditList = (data: AuditListParams) => {
  return http.get("/process/task/idoList", data);
};

/**
 * 我发起
 */
export const myAuditList = (data: AuditListParams) => {
  return http.get("/process/instance/mySubmitted", data);
};

/**
 * 获取审批表单模型/数据/审批记录
 */
export const approvalForm = (taskId: string, nodeId: string) => {
  return http.get(`/process/instance/progress/${taskId}/${nodeId}`);
};

/**
 * 通过定义ID/实例ID 查询审批数据
 */
export const approvalDataByInstanceId = (defId: string, instanceId: string) => {
  return http.get(`/process/instance/detail/${defId}/${instanceId}`);
};

/**
 * 用户处理任务，审批、转交、评论、撤销
 */
export const handlerTask = (data: any) => {
  return http.post(`/process/task/handler`, data);
};

/**
 * 工作台消息&审批数量
 */
export const workbenchMsgNumber = () => {
  return http.get<WorkbenchCount>("/sass/msg/workbenchMsgNumber");
};

/**
 * 工作台消息列表
 */
export const workbenchMsgList = (params: WorkbenchMsgListParams) => {
  return http.get<MsgPageListData>("/sass/msg/workbenchMsgSummaryList", params);
};

/**
 * 消息详情
 */
export const workbenchMsgDetail = (msgId: string) => {
  return http.get(`/sass/msg/detail/${msgId}`);
};

/**
 * 消息处理
 */
export const workbenchMsgHandle = (data: MsgConfirmParams) => {
  return http.post("/sass/msg/treated", data);
};

/**
 * 消息分页列表
 */
export const msgPageList = (params: MsgPageListParams) => {
  return http.get("/sass/msg/pageList", params);
};
/**
 * 消息分页列表 状态数量
 */
export const msgPageListCount = () => {
  return http.get<msgPageListCountData>("/sass/msg/msgNumber");
};
